package com.example.test.shujujiegou;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.AbstractApplicationContext;

/**
 * @author xu
 * @date 2020/11/21
 * @desciption 选择排序
 */
public class SelectSort {


    public static void main(String[] args) {
        int[] arr = {5,3,6,8,1,7,9,4,2};
        int minPos = 0;
        for(int i = 0;i < arr.length; i++){


            for(int j = 1; j < arr.length; j++){
                if(arr[j] < arr[minPos]){
                    minPos = j;
                }
            }

            swap(arr,i,minPos);

        }
        System.out.println("minPos  " + minPos + " 值 : "+ arr[minPos]);
    }


    static void swap(int[] arr ,int i,int j){

        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;

    }


    private void print(){


       // AbstractApplicationContext

//        BeanFactory

    }



}
